/**
 * 
 */
package com.revenco.bi.controller.basecontroller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;

import com.revenco.bi.controller.exception.BusinessException;
import com.revenco.bi.controller.exception.ParameterException;

/**
 * @author LingJun
 * @version $Revision:1.0.0, 2014年1月6日 下午7:54:33 
 */
public abstract class BaseController {
	protected final Logger log = LoggerFactory.getLogger(getClass());
	
//	@ExceptionHandler(Exception.class)
//	@ResponseStatus(HttpStatus.OK)
//	public Map<String,String> handleException(Exception e, HttpServletRequest request){
//		System.out.println(e);
//		Map<String, String> result = new HashMap<String, String>();
//		result.put("error", "错误信息");
//		return result;
//	}
	@ExceptionHandler
	public String exp(HttpServletRequest request, Exception e) {
		System.out.println(e);
		request.setAttribute("ex", e);
		
		// 根据不同错误转向不同页面
		if(e instanceof BusinessException) {
			return "/error/error-business";
		}else if(e instanceof ParameterException) {
			return "/error/error-parameter";
		} else {
			return "/error/error";
		}
	}
}
